-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-8-19
-- Description: DO NOT EDIT; Code generated by "model.lua.mako"
local mdb = require 'mc.mdb'
local class = require 'mc.class_mgnt'
local privilege = require 'mc.privilege'

local my_mds_model_class_types = require 'class.types.MyMDSModel'
local community_intf_types = require 'my_app.json_types.Community'
local properties_intf_types = require 'my_app.json_types.Properties'
local reading_intf_types = require 'my_app.json_types.Reading'

local MyMDSModel = {
    ['prop_configs'] = {
        ['SecretNumber'] = {['baseType'] = 'U32', ['validator'] = my_mds_model_class_types.SecretNumber}
    },
    ['default_props'] = {['SecretNumber'] = my_mds_model_class_types.SecretNumber.default[1]},
    ['mdb_prop_configs'] = {
        ['bmc.demo.OpenUBMC.Community'] = {
            ['WelcomeMessage'] = {['baseType'] = 'String', ['validator'] = community_intf_types.WelcomeMessage}
        },
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_method_configs'] = {
        ['bmc.demo.OpenUBMC.Community'] = {
            ['GetRepoURL'] = {
                ['req'] = {{['baseType'] = 'U32', ['param'] = 'SercretNumber'}},
                ['rsp'] = {{['baseType'] = 'String', ['param'] = 'OutData'}}
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/demo/MyMDSModel/:id'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.demo.OpenUBMC.Community'] = {
            ['property_defaults'] = {['WelcomeMessage'] = community_intf_types.WelcomeMessage.default[1]},
            ['interface_types'] = community_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['interface_types'] = properties_intf_types
        }
    })
}

local MyCSRModel = {
    ['mdb_prop_configs'] = {
        ['bmc.demo.OpenUBMC.Reading'] = {
            ['TemperatureCelsius'] = {
                ['baseType'] = 'S16',
                ['descriptions'] = 'OpenUBMC示例中的温度读值',
                ['usage'] = {'CSR'},
                ['validator'] = reading_intf_types.TemperatureCelsius
            }
        },
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/demo/MyCSRModel/:id'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.demo.OpenUBMC.Reading'] = {
            ['property_defaults'] = {['TemperatureCelsius'] = reading_intf_types.TemperatureCelsius.default[1]},
            ['interface_types'] = reading_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['interface_types'] = properties_intf_types
        }
    })
}

local M = {}

function M.init(bus)
    class('MyMDSModel', MyMDSModel):set_bus(bus)
    class('MyCSRModel', MyCSRModel):set_bus(bus)
end

-- The callback needs to be registered during app initialization
function M.ImplMyMDSModelCommunityGetRepoURL(cb)
    class('MyMDSModel')['bmc.demo.OpenUBMC.Community'].GetRepoURL = function(obj, ctx, ...)
        local req = community_intf_types.GetRepoURLReq.new(...):validate(nil, nil, true)
        local rsp = community_intf_types.GetRepoURLRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

return M
